package com.shhm.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.shhm.common.dto.response.AjaxResultPlus;
import com.shhm.common.entity.system.SysLog;
import com.shhm.common.mapper.LogMapper;
import com.shhm.common.service.LogService;
import com.shhm.common.utils.MybatisPlusUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Service;

/**
 * @author JackZ
 * @version 1.0
 * @description: TODO
 * @date 2025/8/5 下午3:10
 */
@Service
public class LogServiceImpl implements LogService {
    @Resource
    private LogMapper logMapper;

    @Override
    public void save(SysLog log) {
        logMapper.insert(log);
    }

    @Override
    public AjaxResultPlus pageList(Integer pageNum, Integer pageSize, HttpServletRequest request) {
        PageDTO<SysLog> userPage = new PageDTO<>(pageNum, pageSize);
        PageDTO<SysLog> list=logMapper.selectPage(userPage, null);
        return AjaxResultPlus.custom(200, false)
                .put("data",list);
    }

    @Override
    public AjaxResultPlus pageSearchList(Integer pageNum, Integer pageSize, SysLog entity) {
        PageDTO<SysLog> userPage = new PageDTO<>(pageNum, pageSize);
        QueryWrapper<SysLog> qw = MybatisPlusUtil.buildSearchQueryWrapper(entity);
        PageDTO<SysLog> list = logMapper.selectPage(userPage, qw);
        return AjaxResultPlus.success(list,false);
    }
}
